<?php
function setRateDataABC ($num)
{
    global $fieldArr;
    global $table;
    global $orded;
    global $lotto_id;
    global $table;
    global $rate;
    global $bettype;
    global $tableC;
    global $showType;
    if ($bettype == "D" || $bettype == "E")
    {
        setRateDataBySubid($table, $bettype, 0, "r" . $num, 0 - $rate, $tableC . ":" . $num);
    }
    else
    {
        $chkArr = array("A" => "A", "B" => "B", "C" => "C");
        if (!in_array($bettype, $chkArr))
        {
            $tableC = GetBetContent($bettype, $num, 0);
        }
        $rrs = getdb("!!select r" . $num . " From " . $table . $orded . "a where lotto_id=" . $lotto_id);
        if ($orded == "")
        {
            $fieldArr['betcontent'] = $tableC . "A " . $num;
        }
        else
        {
            $fieldArr['betcontent'] = $tableC . $orded . " " . $num;
        }
        $fieldArr['orate'] = $rrs->f["r" . $num];
        $fieldArr['nrate'] = floatval($rrs->f["r" . $num]) + $rate;
        if ($fieldArr['orate'] != $fieldArr['nrate'] && 0 < $fieldArr['nrate'])
        {
            setRateRecord($fieldArr);
            getdb("update " . $table . $orded . "a set r" . $num . " = r" . $num . " + " . $rate . " where lotto_id=" . $lotto_id);
            getdb("update " . $table . $orded . "b set r" . $num . " = r" . $num . " + " . $rate . " where lotto_id=" . $lotto_id);
            getdb("update " . $table . $orded . "c set r" . $num . " = r" . $num . " + " . $rate . " where lotto_id=" . $lotto_id);
            getdb("update " . $table . $orded . "d set r" . $num . " = r" . $num . " + " . $rate . " where lotto_id=" . $lotto_id);
        }
        if ($table == "rate0")
        {
            $rrs = getdb("!!select r" . $num . " From rate24a where lotto_id=" . $lotto_id);
            $fieldArr['betcontent'] = "特码B " . $num;
            $fieldArr['orate'] = $rrs->f["r" . $num];
            $fieldArr['nrate'] = floatval($rrs->f["r" . $num]) + $rate;
            if ($fieldArr['orate'] != $fieldArr['nrate'] && 0 < $fieldArr['nrate'])
            {
                setRateRecord($fieldArr);
                getdb("update rate24a set r" . $num . " = r" . $num . " + " . $rate . " where lotto_id=" . $lotto_id);
                getdb("update rate24b set r" . $num . " = r" . $num . " + " . $rate . " where lotto_id=" . $lotto_id);
                getdb("update rate24c set r" . $num . " = r" . $num . " + " . $rate . " where lotto_id=" . $lotto_id);
                getdb("update rate24d set r" . $num . " = r" . $num . " + " . $rate . " where lotto_id=" . $lotto_id);
            }
        }
        else
        {
            if ($table == "rate4" && $orded == "")
            {
                $rrs = getdb("!!select r" . $num . " From rate31a where lotto_id=" . $lotto_id);
                $fieldArr['betcontent'] = "正码B " . $num;
                $fieldArr['orate'] = $rrs->f["r" . $num];
                $fieldArr['nrate'] = floatval($rrs->f["r" . $num]) + $rate;
                if ($fieldArr['orate'] != $fieldArr['nrate'] && 0 < $fieldArr['nrate'])
                {
                    setRateRecord($fieldArr);
                    getdb("update rate31a set r" . $num . " = r" . $num . " + " . $rate . " where lotto_id=" . $lotto_id);
                    getdb("update rate31b set r" . $num . " = r" . $num . " + " . $rate . " where lotto_id=" . $lotto_id);
                    getdb("update rate31c set r" . $num . " = r" . $num . " + " . $rate . " where lotto_id=" . $lotto_id);
                    getdb("update rate31d set r" . $num . " = r" . $num . " + " . $rate . " where lotto_id=" . $lotto_id);
                }
            }
            else
            {
                if ($table == "rate4" && 0 < intval($orded))
                {
                    $rrs = getdb("!!select br" . $num . " From rate4{$orded}a where lotto_id=" . $lotto_id);
                    $fieldArr['betcontent'] = "正码特B " . $num;
                    $fieldArr['orate'] = $rrs->f["br" . $num];
                    $fieldArr['nrate'] = floatval($rrs->f["br" . $num]) + $rate;
                    if ($fieldArr['orate'] != $fieldArr['nrate'] && 0 < $fieldArr['nrate'])
                    {
                        setRateRecord($fieldArr);
                        getdb("update rate4{$orded}a set br" . $num . " = br" . $num . " + " . $rate . " where lotto_id=" . $lotto_id);
                        getdb("update rate4{$orded}b set br" . $num . " = br" . $num . " + " . $rate . " where lotto_id=" . $lotto_id);
                        getdb("update rate4{$orded}c set br" . $num . " = br" . $num . " + " . $rate . " where lotto_id=" . $lotto_id);
                        getdb("update rate4{$orded}d set br" . $num . " = br" . $num . " + " . $rate . " where lotto_id=" . $lotto_id);
                    }
                }
            }
        }
    }
}

function setRateDataOther ($table, $bettype, $field, $newrate, $content = "")
{
    global $g_betname;
    global $fieldArr;
    global $numbers;
    global $lotto_id;
    $tableC = "";
    $tableC = GetBetContent($bettype, $numbers, 0);
    $tableC = strpos($tableC, "<") ? substr($tableC, 0, strpos($tableC, "<")) : $tableC;
    $tableC = strpos($tableC, " @ ") ? substr($tableC, 0, strpos($tableC, " @ ")) : $tableC;
    $rrs = getdb("!!select r" . $field . " From " . $table . "a where lotto_id=" . $lotto_id);
    $fieldArr['betcontent'] = $tableC . $content;
    $fieldArr['orate'] = $rrs->f["r" . $field];
    $fieldArr['nrate'] = floatval($rrs->f["r" . $field]) - $newrate;
    $ret = 0;
    if ($fieldArr['orate'] != $fieldArr['nrate'] && 0 < $fieldArr['nrate'])
    {
        setRateRecord($fieldArr);
        getdb("update " . $table . "a set r" . $field . " = r" . $field . " - " . $newrate . " where lotto_id=" . $lotto_id);
        getdb("update " . $table . "b set r" . $field . " = r" . $field . " - " . $newrate . " where lotto_id=" . $lotto_id);
        getdb("update " . $table . "c set r" . $field . " = r" . $field . " - " . $newrate . " where lotto_id=" . $lotto_id);
        getdb("update " . $table . "d set r" . $field . " = r" . $field . " - " . $newrate . " where lotto_id=" . $lotto_id);
        if (0 < $fieldArr['orate'])
        {
            $ret = round($fieldArr['nrate'] / $fieldArr['orate'], 4);
        }
    }
    return $ret;
}

function setRateData2Face ($table, $field1, $newrated, $field2, $newrateu)
{
    global $g_betname;
    global $bettype;
    global $fieldArr;
    global $numbers;
    global $lotto_id;
    $tableC = GetBetContent($bettype, $numbers, 0);
    $tableC = strpos($tableC, "<") ? substr($tableC, 0, strpos($tableC, "<")) : $tableC;
    $rrs = getdb("!!select " . $field1 . "," . $field2 . " From " . $table . "a where lotto_id=" . $lotto_id);
    $fieldArr['betcontent'] = $tableC;
    $fieldArr['orate'] = $rrs->f[$field1];
    $fieldArr['nrate'] = floatval($rrs->f[$field1]) - $newrated;
    if ($fieldArr['orate'] != $fieldArr['nrate'] && 0 < $fieldArr['nrate'])
    {
        setRateRecord($fieldArr);
        $num2 = ( substr($numbers, 0, 1) == "1" ? "2" : "1" ) . substr($numbers, 1);
        $tableC = GetBetContent($bettype, $num2, 0);
        $tableC = strpos($tableC, "<") ? substr($tableC, 0, strpos($tableC, "<")) : $tableC;
        $fieldArr['betcontent'] = $tableC;
        $fieldArr['orate'] = $rrs->f[$field2];
        $fieldArr['nrate'] = floatval($rrs->f[$field2]) + $newrateu;
        if ($fieldArr['orate'] != $fieldArr['nrate'])
        {
            setRateRecord($fieldArr);
        }
        getdb("update " . $table . "a set {$field1} = {$field1} - {$newrated}, {$field2} = {$field2} + {$newrateu} where lotto_id=" . $lotto_id);
        getdb("update " . $table . "b set {$field1} = {$field1} - {$newrated}, {$field2} = {$field2} + {$newrateu} where lotto_id=" . $lotto_id);
        getdb("update " . $table . "c set {$field1} = {$field1} - {$newrated}, {$field2} = {$field2} + {$newrateu} where lotto_id=" . $lotto_id);
        getdb("update " . $table . "d set {$field1} = {$field1} - {$newrated}, {$field2} = {$field2} + {$newrateu} where lotto_id=" . $lotto_id);
    }
}
function setRateDataAB ($table, $btype1, $field1, $newrated, $btype2, $field2, $newrateu)
{
    global $g_betname;
    global $bettype;
    global $fieldArr;
    global $numbers;
    global $lotto_id;
	
    $tableC = GetBetContent($btype1, $numbers, 0);
    $tableC = strpos($tableC, "<") ? substr($tableC, 0, strpos($tableC, "<")) : $tableC;
    $rrs = getdb("!!select " . $field1 . "," . $field2 . " From " . $table . "a where lotto_id=" . $lotto_id);
    $fieldArr['betcontent'] = $tableC;
    $fieldArr['orate'] = $rrs->f[$field1];
    $fieldArr['nrate'] = floatval($rrs->f[$field1]) - $newrated;
    if ($fieldArr['orate'] != $fieldArr['nrate'] && 0 < $fieldArr['nrate'])
    {
        setRateRecord($fieldArr);
        $tableC = GetBetContent($btype2, $numbers, 0);
        $tableC = strpos($tableC, "<") ? substr($tableC, 0, strpos($tableC, "<")) : $tableC;
        $fieldArr['betcontent'] = $tableC;
        $fieldArr['orate'] = $rrs->f[$field2];
        $fieldArr['nrate'] = floatval($rrs->f[$field2]) - $newrateu;
        if ($fieldArr['orate'] != $fieldArr['nrate'])
        {
            setRateRecord($fieldArr);
        }
        getdb("update " . $table . "a set {$field1} = {$field1} - {$newrated}, {$field2} = {$field2} - {$newrateu} where lotto_id=" . $lotto_id);
        getdb("update " . $table . "b set {$field1} = {$field1} - {$newrated}, {$field2} = {$field2} - {$newrateu} where lotto_id=" . $lotto_id);
        getdb("update " . $table . "c set {$field1} = {$field1} - {$newrated}, {$field2} = {$field2} - {$newrateu} where lotto_id=" . $lotto_id);
        getdb("update " . $table . "d set {$field1} = {$field1} - {$newrated}, {$field2} = {$field2} - {$newrateu} where lotto_id=" . $lotto_id);
    }
}

function setRateDataBySubid ($table, $bettype, $subid, $field, $newrate, $content = "", $flag = 0)
{
    global $g_betname;
    global $fieldArr;
    global $numbers;
    global $lotto_id;
    global $showType;
    $tableC = "";
    if ($subid != 0)
    {
        $rsb = getdb("!!select " . $field . " From " . $table . " where lotto_id=0 and disk=1 and subid={$subid}");
        $rrs = getdb("!!select " . $field . " From " . $table . " where lotto_id=" . $lotto_id . " and disk=1 and subid={$subid}");
    }
    else
    {
        $salAdd = "";
        if ($showType != 0)
        {
            $salAdd = " and bettype={$showType}";
        }
		if ($table == "rate37")
        {
            $salAdd = " and bettype={$bettype}";
        }
        $rsb = getdb("!!select " . $field . " From " . $table . " where lotto_id=0 and disk=1 {$salAdd}");
        $rrs = getdb("!!select " . $field . " From " . $table . " where lotto_id=" . $lotto_id . " and disk=1 {$salAdd}");
    }
    $max_rate = 1.5;
    $fieldArr['betcontent'] = $content;
    $fieldArr['orate'] = $rrs->f[$field];
    if ($flag == 1)
    {
        $newrate = round($fieldArr['orate'] * ( 1 - $newrate ), 2);
    }
    $fieldArr['nrate'] = floatval($rrs->f[$field]) - $newrate;
    if ($fieldArr['nrate'] < 0 || round($rsb->f[0] * $max_rate, 2) < $fieldArr['nrate'])
    {
        
    }
    else
    {
        if ($fieldArr['orate'] != $fieldArr['nrate'] && 0 < $fieldArr['nrate'])
        {
            setRateRecord($fieldArr);
            if ($subid != 0)
            {
                getdb("update " . $table . " set " . $field . " = " . $field . " - " . $newrate . " where lotto_id=" . $lotto_id . " and disk=1 and subid={$subid}");
                getdb("update " . $table . " set " . $field . " = " . $field . " - " . $newrate . " where lotto_id=" . $lotto_id . " and disk=2 and subid={$subid}");
                getdb("update " . $table . " set " . $field . " = " . $field . " - " . $newrate . " where lotto_id=" . $lotto_id . " and disk=3 and subid={$subid}");
                getdb("update " . $table . " set " . $field . " = " . $field . " - " . $newrate . " where lotto_id=" . $lotto_id . " and disk=4 and subid={$subid}");
            }
            else
            {
                $sqlAdd = "";
                if ($table == "rate29")
                {
                    $sqlAdd = " and bettype = {$showType}";
                }
				elseif ($table == "rate37")
                {
                    $sqlAdd = " and bettype = {$bettype}";
                }
                getdb("update " . $table . " set " . $field . " = " . $field . " - " . $newrate . " where lotto_id=" . $lotto_id . " and disk=1 {$sqlAdd}");
                getdb("update " . $table . " set " . $field . " = " . $field . " - " . $newrate . " where lotto_id=" . $lotto_id . " and disk=2 {$sqlAdd}");
                getdb("update " . $table . " set " . $field . " = " . $field . " - " . $newrate . " where lotto_id=" . $lotto_id . " and disk=3 {$sqlAdd}");
                getdb("update " . $table . " set " . $field . " = " . $field . " - " . $newrate . " where lotto_id=" . $lotto_id . " and disk=4 {$sqlAdd}");
            }
        }
    }
}

if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
//if ($curruser['prev_id'] != 0)
//{
//    exit();
//}
$conf = new Config();
if (isset($_GET['cmd']) && $_GET['cmd'] == "stopnow1")
{
    $conf->set("linebet", date("Hi", systime() - 60));
    $conf->set("waitbet", date("Hi", systime() - 60));
    echo "1";
    exit();
}
if (isset($_GET['cmd']) && $_GET['cmd'] == "stopnow0")
{
    if (date("Hi", systime() - 60) < $conf->get("waitbet"))
    {
        $conf->set("linebet", date("Hi", systime() - 60));
        $conf->set("waitbet", date("Hi", systime() - 60));
    }
    $conf->set("othebet", date("Hi", systime() - 60));
    $conf->set("stopbet", date("Hi", systime() - 60));
    $prot_start = 0;
    $conf->set("protect_start", $prot_start);
    echo "1";
    exit();
}
if (isset($_GET['cmd']) && $_GET['cmd'] == "startprot")
{
    $prot_start = 1;
    $conf->set("protect_start", $prot_start);
    echo "1";
    exit();
}
$gameArr = array(29 => "五不中", 39 => "六不中", 40 => "七不中", 41 => "八不中", 42 => "九不中", 43 => "十不中", 44 => "十一不中", 45 => "十二不中");
$showType = 0;
$lotto_id = intval($_GET['id']);
$bettype = $_GET['bettype'];
$numbers = $_GET['number'];
$rate = $_GET['rate'];
$order_id = isset($_GET['order']) ? $_GET['order'] : "";
$method = isset($_GET['method']) ? intval($_GET['method']) : 0;
$pagename = isset($_GET['pagename']) ? intval($_GET['pagename']) : 0;

$rrs = getdb("select round,open from lotto where id=" . $lotto_id);
$fieldArr = array("method" => $method, "gametype" => 0, "round" => $rrs->f['round'], "lotto_id" => $lotto_id, "betcontent" => "", "orate" => 0, "nrate" => 0, "pagename" => $pagename, "paperopen" => $rrs->f['open']);
if ($bettype == "A" || $bettype == "B" || $bettype == "C" || $bettype == "D" || $bettype == "E")
{
    $table = $bettype == "A" ? "rate0" : "rate4";
    $orded = $bettype == "C" ? $order_id : "";
    switch ($bettype)
    {
        case "A" :
            $tableC = "特码";
            break;
        case "B" :
            $tableC = "正码";
            break;
        case "C" :
            $tableC = "正码特{$order_id}";
            break;
        case "D" :
            $showType = intval(getvar("showType"));
            if (!isset($gameArr[$showType]))
            {
                $showType = 29;
            }
            $tableC = $gameArr[$showType];
            $table = "rate29";
            break;
        case "E" :
            $tableC = "连码:三全中";
            $table = "rate8";
            break;
        default :
            $tableC = "正码";
            break;
    }
    $rate = floatval($rate);
    switch ($numbers)
    {
        case 11 :
            foreach ($g_red_po as $n)
            {
                $n2 = str_pad($n, 2, "0", STR_PAD_LEFT);
                setRateDataABC($n2);
            }
            break;
        case 12 :
            foreach ($g_blue_po as $n)
            {
                $n2 = str_pad($n, 2, "0", STR_PAD_LEFT);
                setRateDataABC($n2);
            }
            break;
        case 13 :
            foreach ($g_green_po as $n)
            {
                $n2 = str_pad($n, 2, "0", STR_PAD_LEFT);
                setRateDataABC($n2);
            }
            break;
        case 14 :
            $i = 1;
            while ($i < 49)
            {
                if ($i % 2 == 1)
                {
                    $n2 = str_pad($i, 2, "0", STR_PAD_LEFT);
                    setRateDataABC($n2);
                }
                ++$i;
            }
            break;
        case 15 :
            $i = 1;
            while ($i < 49)
            {
                if ($i % 2 == 0)
                {
                    $n2 = str_pad($i, 2, "0", STR_PAD_LEFT);
                    setRateDataABC($n2);
                }
                ++$i;
            }
            break;
        case 16 :
            $i = 25;
            while ($i < 49)
            {
                $n2 = str_pad($i, 2, "0", STR_PAD_LEFT);
                setRateDataABC($n2);
                ++$i;
            }
            break;
        case 17 :
            $i = 1;
            while ($i < 25)
            {
                $n2 = str_pad($i, 2, "0", STR_PAD_LEFT);
                setRateDataABC($n2);
                ++$i;
            }
            break;
        case 18 :
            foreach ($g_sumnum_odd as $i)
            {
                $n2 = str_pad($i, 2, "0", STR_PAD_LEFT);
                setRateDataABC($n2);
            }
            break;
        case 19 :
            foreach ($g_sumnum_even as $i)
            {
                $n2 = str_pad($i, 2, "0", STR_PAD_LEFT);
                setRateDataABC($n2);
            }
            break;
        case 20 :
            $i = 1;
            while ($i < 50)
            {
                $n2 = str_pad($i, 2, "0", STR_PAD_LEFT);
                setRateDataABC($n2);
                ++$i;
            }
            break;
        case 21 :
            $top10 = split(",", $_GET['top10']);
            foreach ($top10 as $i)
            {
                $i = intval($i);
                if (0 < $i)
                {
                    $n2 = str_pad($i, 2, "0", STR_PAD_LEFT);
                    setRateDataABC($n2);
                }
            }
            break;
        case 22 :
            foreach ($g_sumnum_dom as $i)
            {
                $n2 = str_pad($i, 2, "0", STR_PAD_LEFT);
                setRateDataABC($n2);
            }
            break;
        case 23 :
            foreach ($g_sumnum_wild as $i)
            {
                $n2 = str_pad($i, 2, "0", STR_PAD_LEFT);
                setRateDataABC($n2);
            }
            break;
        case 24 :
            $top05 = split(",", $_GET['top05']);
            foreach ($top05 as $i)
            {
                $i = intval($i);
                if (0 < $i)
                {
                    $n2 = str_pad($i, 2, "0", STR_PAD_LEFT);
                    setRateDataABC($n2);
                }
            }
            break;
        case 25 :
            foreach ($g_red_po as $n)
            {
                if ($n % 2 != 0)
                {
                    $n2 = str_pad($n, 2, "0", STR_PAD_LEFT);
                    setRateDataABC($n2);
                }
            }
            break;
        case 26 :
            foreach ($g_red_po as $n)
            {
                if ($n % 2 == 0)
                {
                    $n2 = str_pad($n, 2, "0", STR_PAD_LEFT);
                    setRateDataABC($n2);
                }
            }
            break;
        case 27 :
            foreach ($g_red_po as $n)
            {
                if (24 < $n)
                {
                    $n2 = str_pad($n, 2, "0", STR_PAD_LEFT);
                    setRateDataABC($n2);
                }
            }
            break;
        case 28 :
            foreach ($g_red_po as $n)
            {
                if ($n < 25)
                {
                    $n2 = str_pad($n, 2, "0", STR_PAD_LEFT);
                    setRateDataABC($n2);
                }
            }
            break;
        case 29 :
            foreach ($g_blue_po as $n)
            {
                if ($n % 2 != 0)
                {
                    $n2 = str_pad($n, 2, "0", STR_PAD_LEFT);
                    setRateDataABC($n2);
                }
            }
            break;
        case 30 :
            foreach ($g_blue_po as $n)
            {
                if ($n % 2 == 0)
                {
                    $n2 = str_pad($n, 2, "0", STR_PAD_LEFT);
                    setRateDataABC($n2);
                }
            }
            break;
        case 31 :
            foreach ($g_blue_po as $n)
            {
                if (24 < $n)
                {
                    $n2 = str_pad($n, 2, "0", STR_PAD_LEFT);
                    setRateDataABC($n2);
                }
            }
            break;
        case 32 :
            foreach ($g_blue_po as $n)
            {
                if ($n < 25)
                {
                    $n2 = str_pad($n, 2, "0", STR_PAD_LEFT);
                    setRateDataABC($n2);
                }
            }
            break;
        case 33 :
            foreach ($g_green_po as $n)
            {
                if ($n % 2 != 0)
                {
                    $n2 = str_pad($n, 2, "0", STR_PAD_LEFT);
                    setRateDataABC($n2);
                }
            }
            break;
        case 34 :
            foreach ($g_green_po as $n)
            {
                if ($n % 2 == 0)
                {
                    $n2 = str_pad($n, 2, "0", STR_PAD_LEFT);
                    setRateDataABC($n2);
                }
            }
            break;
        case 35 :
            foreach ($g_green_po as $n)
            {
                if (24 < $n)
                {
                    $n2 = str_pad($n, 2, "0", STR_PAD_LEFT);
                    setRateDataABC($n2);
                }
            }
            break;
        case 36 :
            foreach ($g_green_po as $n)
            {
                if ($n < 25)
                {
                    $n2 = str_pad($n, 2, "0", STR_PAD_LEFT);
                    setRateDataABC($n2);
                }
            }
            break;
        case 37 :
            $i = 1;
            while ($i < 49)
            {
                $n2 = str_pad($i, 2, "0", STR_PAD_LEFT);
                $ss = substr($n2, 0 - 1);
                if (4 < $ss)
                {
                    setRateDataABC($n2);
                }
                ++$i;
            }
            break;
        case 38 :
            $i = 1;
            while ($i < 49)
            {
                $n2 = str_pad($i, 2, "0", STR_PAD_LEFT);
                $ss = substr($n2, 0 - 1);
                if ($ss < 5)
                {
                    setRateDataABC($n2);
                }
                ++$i;
            }
            break;
        case 39 :
            $i = 1;
            while ($i < 50)
            {
                if ($i != 25)
                {
                    $n2 = str_pad($i, 2, "0", STR_PAD_LEFT);
                    $sp = intval(substr($n2, 0, 1)) + intval(substr($n2, 0 - 1));
                    $ss = substr($sp, 0 - 1);
                    if (4 < $ss)
                    {
                        setRateDataABC($n2);
                    }
                }
                ++$i;
            }
            break;
        case 40 :
            $i = 1;
            while ($i < 50)
            {
                if ($i != 25)
                {
                    $n2 = str_pad($i, 2, "0", STR_PAD_LEFT);
                    $sp = intval(substr($n2, 0, 1)) + intval(substr($n2, 0 - 1));
                    $ss = substr($sp, 0 - 1);
                    if ($ss < 5)
                    {
                        setRateDataABC($n2);
                    }
                }
                ++$i;
            }
            break;
    }
}
else
{
    $bettype = intval($bettype);
    $btype = $bettype;
    switch ($bettype)
    {
        case 37 :
            $btype = 21;
            break;
        case 38 :
            $btype = 22;
            break;
    }
    $arRs = getdb("SELECT * FROM autorate_config_6h WHERE bettype_id={$btype} AND subid=0 LIMIT 1");
    switch ($bettype)
    {
        case 0 :
        case 24 :
            $newrate = 0 - $rate;
            setRateDataOther("rate0", 0, $numbers, $newrate);
            setRateDataOther("rate24", 24, $numbers, $newrate);
            break;
        case 4 :
        case 31 :
            $newrate = 0 - $rate;
            setRateDataOther("rate4", 4, $numbers, $newrate);
            setRateDataOther("rate31", 31, $numbers, $newrate);
            break;
        case 1 :
        case 2 :
        case 3 :
        case 20 :
        case 28 :
        case 30 :
        case 35 :
        case 47 :
            $newrateu = $arRs->f['uprate1'];
            $newrated = $arRs->f['downrate1'];
            $newrateu = 0 - $newrateu * $rate;
            $newrated = 0 - $newrated * $rate;
            $n1 = "r" . $bettype . "_1";
            $n2 = "r" . $bettype . "_2";
            if ($numbers == 2)
            {
                $n1 = "r" . $bettype . "_2";
                $n2 = "r" . $bettype . "_1";
            }
            setRateData2Face("rate1", $n1, $newrated, $n2, $newrateu);
            break;
        case 13 :
        case 14 :
        case 18 :
        case 34 :
        case 46 :
			$newrate = $arRs->f['downrate1'];
            $newrate = 0 - $newrate * $rate;
            $n1 = $bettype . "_" . $numbers;
            setRateDataOther("rate1", $bettype, $n1, $newrate);
            break;
		case 49 :
			$n = intval($numbers);
            $n1 = "r" . $n;
            $content = "特码头：头".$n;
            setRateDataBySubid("rate37", $bettype, 0, $n1, $rate * ( 0 - 1 ), $content);
			echo $rate * ( 0 - 1 );
            break; 
		case 50 :
        	$n = intval($numbers);
            $n1 = "r" . $n;
            $content = "特码尾：尾".$n;
            setRateDataBySubid("rate37", $bettype, 0, $n1, $rate * ( 0 - 1 ), $content);
            break;    
        case 21 :
        case 37 :
            $newrate = $arRs->f['downrate1'];
            $newrate = 0 - $newrate * $rate;
            $n1 = "21_" . $numbers;
            $retx = setRateDataOther("rate1", 21, $n1, $newrate);
            $n1 = "37_" . $numbers;
            setRateDataOther("rate1", 37, $n1, $newrate);

            if (0 < $retx && $bettype == 21 && intval($conf->get("bettype21_27")) == 1)
            {
                $subid = 2;
                while ($subid <= 5)
                {
                    $n1 = "r" . d2($numbers);
                    $content = $subid . "肖_" . $g_chinayear[$numbers];
                    setRateDataBySubid("rate27", $bettype, $subid, $n1, $retx, $content, 1);
                    ++$subid;
                }
            }
            break;
        case 22 :
        case 38 :
            $newrate = $arRs->f['downrate1'];
            $newrate = 0 - $newrate * $rate;
            $n1 = "22_" . $numbers;
            setRateDataOther("rate1", 22, $n1, $newrate);
            $n1 = "38_" . $numbers;
            setRateDataOther("rate1", 38, $n1, $newrate);
            break;
        case 19 :
            $newrate = $arRs->f['downrate1'];
            $newrate = 0 - $newrate * $rate;
            $subid1 = substr($numbers, 0, 1);
            $subid2 = $subid1 == 1 ? 2 : 1;
            $n0 = substr($numbers, 0 - 3);
            $n1 = "r19_{$subid1}" . $n0;
            $n2 = "r19_{$subid2}" . $n0;
            setRateData2Face("rate1", $n1, $newrate, $n2, 0);
            break;
        case 5 :
        case 6 :
            $newrateu = $arRs->f['uprate1'];
            $newrated = $arRs->f['downrate1'];
            $newrateu = 0 - $newrateu * $rate;
            $newrated = 0 - $newrated * $rate;
            $n1 = "r" . $bettype . "_1";
            $n2 = "r" . $bettype . "_2";
            if ($numbers == 2)
            {
                $n1 = "r" . $bettype . "_2";
                $n2 = "r" . $bettype . "_1";
            }
            setRateData2Face("rate5", $n1, $newrated, $n2, $newrateu);
            break;
        case 15 :
        case 16 :
        case 17 :
        case 23 :
            $nn = split(" ", $numbers);
            $num1 = $nn[0];
            $num2 = $nn[1];
            if (7 < $num2)
            {
                $newrateu = $arRs->f['uprate1'];
                $newrated = $arRs->f['downrate1'];
                if ($num2 == 8)
                {
                    $n1 = "r15_" . $num1 . "_8";
                    $n2 = "r15_" . $num1 . "_9";
                }
                else
                {
                    $n1 = "r15_" . $num1 . "_9";
                    $n2 = "r15_" . $num1 . "_8";
                }
                $newrateu = 0 - $newrateu * $rate;
                $newrated = 0 - $newrated * $rate;
                setRateData2Face("rate15", $n1, $newrated, $n2, $newrateu);
            }
            else
            {
                if (4 < $num2)
                {
                    $n1 = "15_" . $num1 . "_" . $num2;
                    $newrate = $arRs->f['downrate1'];
                    $newrate = 0 - $newrate * $rate;
                    setRateDataOther("rate15", $bettype, $n1, $newrate);
                }
                else
                {
                    if ($num2 == 1)
                    {
                        $n1 = "r15_" . $num1 . "_1";
                        $n2 = "r15_" . $num1 . "_2";
                    }
                    else if ($num2 == 2)
                    {
                        $n1 = "r15_" . $num1 . "_2";
                        $n2 = "r15_" . $num1 . "_1";
                    }
                    else if ($num2 == 3)
                    {
                        $n1 = "r15_" . $num1 . "_3";
                        $n2 = "r15_" . $num1 . "_4";
                    }
                    else if ($num2 == 4)
                    {
                        $n1 = "r15_" . $num1 . "_4";
                        $n2 = "r15_" . $num1 . "_3";
                    }
                    $newrateu = $arRs->f['uprate1'];
                    $newrated = $arRs->f['downrate1'];
                    $newrateu = 0 - $newrateu * $rate;
                    $newrated = 0 - $newrated * $rate;
                    setRateData2Face("rate15", $n1, $newrated, $n2, $newrateu);
                }
            }
            break;
			
        case 25 :
        case 26 :
            $newrate = 0 - $rate;
            $n1 = "r" . $numbers;
            $n2 = "br" . $numbers;
            $numbers = $order_id . " " . $numbers;
            setRateDataAB("rate4" . $order_id, 25, $n1, $newrate, 26, $n2, $newrate);
            break;
        case 7 :
        case 9 :
        case 33 :
        case 10 :
        case 32 :
        case 11 :
            if ($bettype == 9 || $bettype == 33)
            {
                $content = $numbers == 1 ? "中二" : "中三";
            }
            else if ($bettype == 10 || $bettype == 32)
            {
                $content = $numbers == 1 ? "中特" : "中二";
            }
            $n1 = $bettype . "_" . $numbers;
            setRateDataOther("rate5", $bettype, $n1, $rate * ( 0 - 1 ), $content);
            break;
        case 27 :
            $n = explode("_", $numbers);
            $subid = intval($n[0]);
            $n1 = "r" . d2($n[1]);
            $content = $subid . "肖_" . $g_chinayear[$n[1]];
            setRateDataBySubid("rate27", $bettype, $subid, $n1, $rate * ( 0 - 1 ), $content);
            break;
		case 48 :
            $begin = $numbers;
            $end = $numbers;
            if ($numbers == 0)
            {
                $begin = 1;
                $end = 49;
            }
            $i = $begin;
            while ($i <= $end)
            {
                $n1 = "r" . d2($i);
                $content = "四全中:" . d2($i);
                setRateDataBySubid("rate9", $bettype, 0, $n1, $rate * ( 0 - 1 ), $content);
                ++$i;
            }
            break;
        case 8 :
            $begin = $numbers;
            $end = $numbers;
            if ($numbers == 0)
            {
                $begin = 1;
                $end = 49;
            }
            $i = $begin;
            while ($i <= $end)
            {
                $n1 = "r" . d2($i);
                $content = "三全中:" . d2($i);
                setRateDataBySubid("rate" . $bettype, $bettype, 0, $n1, $rate * ( 0 - 1 ), $content);
                ++$i;
            }
            break;
        case 29 :
        case 39 :
        case 40 :
        case 41 :
        case 42 :
        case 43 :
        case 44 :
        case 45 :
            $showType = intval(getvar("showType"));
            if (!isset($gameArr[$showType]))
            {
                $showType = 29;
            }
            $begin = $numbers;
            $end = $numbers;
            if ($numbers == 0)
            {
                $begin = 1;
                $end = 49;
            }
            $i = $begin;
            while ($i <= $end)
            {
                $n1 = "r" . d2($i);
                $content = $gameArr[$showType] . d2($i);
                setRateDataBySubid("rate29", $showType, 0, $n1, $rate * ( 0 - 1 ), $content);
                ++$i;
            }
            break;
        case 36 :
            $n = explode("_", $numbers);
            $subid = intval($n[0]);
            $n1 = "r" . $n[1];
            $content = "连尾_" . $subid . "尾_" . $n[1];
            setRateDataBySubid("rate36", $bettype, $subid, $n1, $rate * ( 0 - 1 ), $content);
            break;
    }
}
?>